// src/chat/schemas/chat-message.schema.ts
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';

@Schema({ timestamps: true }) // 自动添加 createdAt 和 updatedAt 字段
export class ChatMessage extends Document {
  @Prop({ required: true })
  senderId: string; // 发送者 ID

  @Prop({ required: true })
  receiverId: string; // 接收者 ID

  @Prop({ required: true })
  message: string; // 消息内容


  @Prop({ default: false })
  read: boolean;
}

export const ChatMessageSchema = SchemaFactory.createForClass(ChatMessage);